package com.sgj.controller;

import com.sgj.pojo.Stu;
import com.sgj.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 沈国纪
 * @date 2021/7/5 13:14
 */
@RestController
public class StuFooController {

	@Autowired
	private StuService stuService;

	/**
	 * 获取学生信息
	 * @param id
	 * @return
	 */
	@GetMapping("/getStu/{id}")
	public Object getStu(@PathVariable("id") int id) {
		return stuService.getStuInfo(id);
	}

	/**
	 * 保存学生信息
	 * @param stu
	 * @return
	 */
	@PostMapping("/saveStu")
	public Object saveStu(@RequestBody Stu stu) {
		stuService.saveStu(stu);
		return "save success";
	}

	/**
	 * 修改学生信息
	 * @param stu
	 * @return
	 */
	@PostMapping("/updateStu")
	public Object updateStu(@RequestBody Stu stu) {
		stuService.updateStu(stu);
		return "update success";
	}

	/**
	 * 删除学生信息
	 * @param id
	 * @return
	 */
	@PostMapping("/deleteStu/{id}")
	public Object deleteStu(@PathVariable("id") int id) {
		stuService.deleteStu(id);
		return "delete success";
	}
}